package me.aartikov.advancedscreenswitchersample;

import me.aartikov.alligator.animations.AnimationData;
import me.aartikov.alligator.animations.SimpleTransitionAnimation;
import me.aartikov.alligator.animations.TransitionAnimation;
import me.aartikov.alligator.screenswitchers.FragmentScreenSwitcher;
import me.aartikov.alligator.Screen;

import java.util.List;


public class SampleScreenSwitcherAnimationProvider implements FragmentScreenSwitcher.AnimationProvider {
    private List<Screen> mTabScreens;

    public SampleScreenSwitcherAnimationProvider(List<Screen> tabScreens) {
        mTabScreens = tabScreens;
    }

    @Override
    public TransitionAnimation getAnimation(Screen screenFrom, Screen screenTo, AnimationData animationData) {
        int indexFrom = mTabScreens.indexOf(screenFrom);
        int indexTo = mTabScreens.indexOf(screenTo);
        if (indexFrom < indexTo) {//左移
            return new SimpleTransitionAnimation(SimpleTransitionAnimation.RIRHT, SimpleTransitionAnimation.LEFT);
        } else {//右移
            return new SimpleTransitionAnimation(SimpleTransitionAnimation.LEFT, SimpleTransitionAnimation.RIRHT);
        }
    }
}
